package com.example.demo.chacheable;

import com.example.demo.async.CacheAsync;
import com.example.demo.testvo.UserVO;
import com.fasterxml.jackson.annotation.JsonAlias;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class RedisService {

  @Cacheable(value = "getalluser",key = "#root.methodName"+".concat('[400][SS]')")
  public List<UserVO> getalluser2() {
    try {
      Thread.sleep(4000);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    UserVO user1 = new UserVO("bigsai", "12345", "man");
    UserVO user2 = new UserVO("zxczxc", "谢谢", "man");
    List<UserVO> list = new ArrayList<>();
    list.add(user1);
    list.add(user2);
    return list;
  }
  @CacheAsync
  public List<UserVO> aaa() {
    try {
      Thread.sleep(4000);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    UserVO user1 = new UserVO("bigsai", "12345", "man");
    UserVO user2 = new UserVO("zxczxc", "谢谢", "man");
    List<UserVO> list = new ArrayList<>();
    list.add(user1);
    list.add(user2);
    return list;
  }
}
